package org.kaindorf.kainflix.metadata.repository.entity;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamImplicit;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.NotEmpty;

@Entity
@XStreamAlias("metadata")
@Table(uniqueConstraints = {
    @UniqueConstraint(columnNames = {"productId", "indentifier"}) // only one metadata per product per indentifier
})
public class Metadata implements Serializable {

    @Id
    @Column(nullable = false)
    @GeneratedValue
    private Long id;

    @NotNull
    @Column(nullable = false)
    private Long productId;

    @NotEmpty
    @Column(nullable = false)
    private String indentifier;

    @NotEmpty
    @Column(name = "dataValue", nullable = false) // had to be renamed for db because value is a reserved keyword
    private String value;

    public Metadata() {
    }

    public Metadata(Long productId, String indentifier, String value) {
        this.productId = productId;
        this.indentifier = indentifier;
        this.value = value;
    }

    public Long getId() {
        return id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public String getIndentifier() {
        return indentifier;
    }

    public void setIndentifier(String indentifier) {
        this.indentifier = indentifier;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

}
